package com.bi.onlineEducation.domain;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;

import javax.persistence.*;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Date;

/**
 * course
 *
 * @author
 */
@Entity
@Accessors(chain = true)
@Table(name = "course")
@ApiModel(value = "generate.Course课程信息")
@Data
public class CoursePo implements Serializable {
    /**
     * 课程主键id
     */
    @Id
    @Column(name = "c_id")
    @GeneratedValue(generator = "JDBC")
    @ApiModelProperty(value = "课程主键id")
    private Integer cId;

    /**
     * 课程名称
     */
    @Column(name = "c_name")
    @ApiModelProperty(value = "课程名称")
    private String cName;

    /**
     * 课程类别
     */
    @Column(name = "ct_id")
    @ApiModelProperty(value = "课程类别")
    private Integer ctId;

    @OneToOne//sales_order是关系的维护端，当删除 sales_order，会级联删除 person
    @JoinColumn(name = "ct_id", referencedColumnName = "ct_id",insertable=false,updatable=false, nullable=true,foreignKey = @ForeignKey(name = "none",value = ConstraintMode.NO_CONSTRAINT))//sales_order中的bykh字段参考person表中的id字段
    private CourseTypePo courseType;    //PurchasePo中的c_id字段参考CoursePo表中的id字段

    /**
     * 单价
     */
    @Column(name = "c_price")
    @ApiModelProperty(value = "单价")
    private BigDecimal cPrice;

    /**
     * 审核状态：0未通过1已通过
     */
    @Column(name = "c_status")
    @ApiModelProperty(value = "审核状态：0未通过1已通过")
    private Boolean cStatus;

    /**
     * 课程时长
     */
    @Column(name = "c_total_duration")
    @ApiModelProperty(value = "课程时长")
    private Integer cTotalDuration;

    /**
     * 观看路径
     */
    @Column(name = "watch_path")
    @ApiModelProperty(value = "观看路径")
    private String watchPath;

    /**
     * 上传人
     */
    @Column(name = "l_id")
    @ApiModelProperty(value = "上传人")
    private Integer lId;

    @OneToOne(cascade = CascadeType.DETACH)//PurchasePo是关系的维护端，当删除 PurchasePo，会级联删除 CoursePo
    @JoinColumn(name = "l_id", referencedColumnName = "l_id", insertable = false, updatable = false)
    private LoginPo login;    //PurchasePo中的c_id字段参考CoursePo表中的id字段

    /**
     * 上传时间
     */
    @Column(name = "create_time")
    @ApiModelProperty(value = "上传时间")
    private Date createTime;

    /**
     * 课程描述
     */
    @Column(name = "c_desc")
    @ApiModelProperty(value = "课程描述")
    private String cDesc;

    private static final long serialVersionUID = 1L;
}